package com.zhuss.controller.core;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.zhuss.bean.bo.core.resource.CreateResourceBo;
import com.zhuss.bean.bo.core.resource.DeleteResourceBo;
import com.zhuss.bean.bo.core.resource.ResourcePermissionBindBo;
import com.zhuss.bean.bo.core.resource.UpdateResourceBo;
import com.zhuss.common.BaseController;
import com.zhuss.common.OperateService;
import com.zhuss.core.menu.ResourceOperateServiceExt;
import com.zhuss.exception.OceanException;


/**
 * 菜单资源点操作 controller
 * @Author zhushanshuo
   @Date 2019-12-27 18:51
 *
 */
  
 
@RestController
@RequestMapping("/resource")
public class ResourceOperateController extends BaseController {
	
	@Autowired
	@Qualifier("resourceOperateService")
	private OperateService<Void, Object> resourceOperateService;
	
	@Autowired
	@Qualifier("resourceOperateServiceExt")
	private ResourceOperateServiceExt resourceOperateServiceExt;
	
	/**
	 * 创建
	 * @param bo
	 * @throws OceanException
	 */
	@ResponseBody
    @PostMapping("/create")
    public void create(@RequestBody CreateResourceBo bo) throws OceanException {
		
		resourceOperateService.create(bo);
    }
	
	/**
	 * 修改
	 * @param bo
	 * @throws OceanException
	 */
	@ResponseBody
    @PostMapping("/update")
    public void update(@RequestBody UpdateResourceBo bo) throws OceanException {
		
		resourceOperateService.update(bo);
    }
	
	/**
	 * 删除
	 * @param bo
	 * @throws OceanException
	 */
	@ResponseBody
    @PostMapping("/delete")
    public void delete(@RequestBody DeleteResourceBo bo) throws OceanException {
		
		resourceOperateService.delete(bo);
    }
	
	/**
	 * 给菜单资源绑定权限点
	 * @param bo
	 * @throws OceanException
	 */
	@ResponseBody
    @PostMapping("/resourcePermissionBind")
    public void resourcePermissionBind(@RequestBody ResourcePermissionBindBo bo) throws OceanException {
		
		resourceOperateServiceExt.resourcePermissionBind(bo);
    }


	
}
